package clienteWeb;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import interfaces.RemoteInterface;

public class ControladorWeb {

	private static ControladorWeb instancia;
	private RemoteInterface controladorRMI;

	public static void main(String[] args) {
		new ControladorWeb();
	}

	public static ControladorWeb getInstancia()
	{
		if(instancia==null)
		{
			return instancia=new ControladorWeb();
		}
		return instancia;
	}

	public ControladorWeb()
	{
		instancia=this;
		this.getStub();
	}

	private boolean getStub()
	{
		try {
			controladorRMI=(RemoteInterface)Naming.lookup("//localhost/RemoteBusiness");
			System.out.println("Me pude conectar al server");
			return true;
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return false;
	}

}
